import unittest
import requests
import jsonpath, json
from common.config_utils import config
from common import pubilc_api_info


class TestsGetAccessTokenApi(unittest.TestCase):
    def setUp(self) -> None:
        self.hosts = config.HOSTS
        self.session = requests.session()

    def tearDown(self) -> None:
        self.session.close()

    def test_01_create_user_tag(self):
        self._testMethodName = '创建标签'
        self._testMethodDoc = '创建标签接口'
        token_id=pubilc_api_info.get_access_token(self.session)

        url_params = {
            "access_token": token_id
        }
        post_data_json = {"tag": {"name": "岳阳2"}}
        response = pubilc_api_info.create_user_tag_api(self.session, url_params, post_data_json)
        actual_result = jsonpath.jsonpath(response.json(), '$.tag.name')[0]
        self.assertEqual(actual_result, '岳阳2')


if __name__ == '__main__':
    unittest.main(verbosity=2)
